New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

telefone

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telefone

Biblioteca para validar facilmente telefones brasileiros

1.2.5
latest
Source
npm
Version published
Weekly downloads
210
20.69%
Maintainers
0
Weekly downloads
 
Created
Source

telefone

npm-version coverage status known vulnerabilities downloads license

Biblioteca para validar e formatar facilmente telefones brasileiros

O objetivo desta biblioteca é ser leve e oferecer métodos simples e garantidos para validação e formatação básica de telefones brasileiros.

Install

npm i telefone

Como importar

const parse = require('telefone/parse');
// ou
const { parse } = require('telefone');
// ou
const parse = require('telefone').parse;

const format = require('telefone/format');
// ou
const { format } = require('telefone');
// ou
const format = require('telefone').format;

parse(str)

const parse = require('telefone/parse');
console.log(parse("+55 (21) 97864-2213")); //retorna 21978642213
console.log(parse("(21) 00000-0000")); //retorna null, pois o telefone é inválido
console.log(parse("+55 (21) 97864-2213", { apenasFixo: true })); //retorna null, pois o telefone não é fixo
console.log(parse("+55 (21) 4002-8922", { apenasCelular: true })); //retorna null, pois o telefone não é celular
console.log(parse("+55 (21) 4002-8922", { apenasDDD: [ '11', '24' ] })); //retorna null, pois o telefone não é de um dos DDDs informados

format(str)

const format = require('telefone/format');
console.log(format("+55 2197864 2213")); //retorna (21) 97864-2213
console.log(format("+5521 4002 8922")); //retorna (21) 4002-8922
console.log(format("2140028922")); //retorna (21) 4002-8922

Posso usar em produção?

Deve. Essa biblioteca tem uma política estrita de 100% de cobertura. Além disso, ela tem sido usada internamente em produção desde 2019.

Licença

MIT License

Copyright (c) 2019-2025 Patrick Pissurno

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

telefone

FAQs

Package last updated on 26 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts